﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
using AgileNYCWebService.Manager.Data.Table;
using Newtonsoft.Json;

namespace AgileNYCWebService
{
	public partial class Sync : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			try
			{
                //string url = "http://localhost:19368/AgileSync.svc/Contacts";
				//string url = "http://81.95.226.86:84/AgileSync.svc/Contacts";
			//	string url = "http://localhost:19368/AgileUsers.svc/AddNote";
                string url = "http://rapidsquere.cloudapp.net/AgileSync.svc/Contacts";

				SyncClass syncClass = new SyncClass();
                syncClass.UserToken = "8de67d5a390744569f8f9e4d8da60ebd";

                syncClass.ModifiedDate = "2012-10-08 06:43:05";

				/*Note note = new Note();
				note.UserToken = "a6vRPEPXwUOR1iWQle27Cg==";
				note.Code = 7393;
				note.NoteText = "Dfdsfsdfds sefsdfds  45664";*/

				System.Net.WebRequest webReq = System.Net.WebRequest.Create(url);
				webReq.Method = "POST";
				//webReq.ContentType = "text/plain; charset=utf-8";
				webReq.ContentType = "application/json; charset=utf-8";

				StreamWriter writer = new StreamWriter(webReq.GetRequestStream());
				string yourdata = JsonConvert.SerializeObject(syncClass);
				writer.Write(yourdata);
				writer.Close();

				System.Net.WebResponse webResp = webReq.GetResponse();
				System.IO.StreamReader sr = new System.IO.StreamReader(webResp.GetResponseStream());
				String s = sr.ReadToEnd().Trim();
				string result = s;
			}
			catch (Exception ex)
			{
			}
		}
	}
}